package com.atom.data;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.atom.annotation.ApiImpl;
import com.atom.core.ApiImplRouter;

@ApiImpl(api = Activity.class, name = "data")
public class FromDataActivity extends AppCompatActivity {

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        TextView view = new TextView(this);
        view.setText("我来自Data模块");
        view.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(FromDataActivity.this, "跳转到App Activity", Toast.LENGTH_SHORT).show();
                ApiImplRouter.getInstance().getApi(Activity.class, "main", (apiImplContext, aClass) -> {
                    startActivity(new Intent(FromDataActivity.this, aClass));
                    finish();
                });
            }
        });
        setContentView(view);
    }
}
